package com.itqf.demo02;

import com.itqf.job.MyJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @Description:  Scheduler   JobDetail（Job）  Trigger
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/11/19
 * @Time: 上午11:45
 */
public class TestCronTrigger {

    public  static  void  main(String[]args) throws  Exception{
        //1,创建调度器
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        //2,构建JObDetail
        JobDetail jobDetail = JobBuilder.newJob(MyJob.class)
                .withIdentity("myJob","myGroup").build();

        //3,创建触发器
        CronTrigger cronTrigger = TriggerBuilder.newTrigger()
                .withSchedule(CronScheduleBuilder.cronSchedule("0/2 * * 19 11 ?"))
                .withIdentity("myTrigger")
                .build();
        //4,注册触发器和任务
        scheduler.scheduleJob(jobDetail,cronTrigger);


        //5,开启任务
        scheduler.start();

        Thread.sleep(10000);

        scheduler.shutdown();//关闭任务

        //练习：11月的19号的12点的每分钟的1,5,9,12秒的时候执行


    }


}
